package advance_2;
import  java.util.*;
public class SetTest {
    public static void main(String[] args) {
        Set set=new HashSet();
        set.add("dog");
        set.add("dog");
        set.add("tiger");
        set.add(new Dog("小花花"));
        set.add(new Dog("小花花"));
        System.out.println("size:"+set.size());
        System.out.println(set);
        System.out.println(">>>>>>>>迭代>>>>>>>>>>>>>>>");
        System.out.println("1::转换成数组:");
        Object[]ar=set.toArray();
        System.out.println("2::使用迭代器:");
        Iterator ir=set.iterator();
        //hasNext...next
        while(ir.hasNext()){
            Object o=ir.next();
            System.out.println(o+">>"+o.getClass());
        }
        System.out.println(">>>>>>>增强for>>>>>>>>>");
        for(Object o:set){
            System.out.println(o);
        }
    }
}
